package cn.chengpengper.seckill.stock.domain.model.entity;

import cn.chengpengper.seckill.common.utils.id.SnowFlakeFactory;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author chengpeng.hu
 */
@Data
@Builder
@AllArgsConstructor
public class SeckillStockBucket implements Serializable {

    private static final long serialVersionUID = 3785550010469672595L;

    /**
     * 数据库主键ID
     */
    private Long id;

    /**
     * 商品ID
     */
    private Long goodsId;

    /**
     * 初始库存
     */
    private Integer initialStock;

    /**
     * 当前可用库存
     */
    private Integer availableStock;

    /**
     * 状态,0:不可用，1:可用
     */
    private Integer status;

    /**
     * 分桶编号
     */
    private Integer serialNo;

    public SeckillStockBucket() {
    }

    public SeckillStockBucket(Long goodsId, Integer initialStock, Integer availableStock, Integer status, Integer serialNo) {
        this.id = SnowFlakeFactory.getSnowFlakeFromCache().nextId();
        this.goodsId = goodsId;
        this.initialStock = initialStock;
        this.availableStock = availableStock;
        this.status = status;
        this.serialNo = serialNo;
    }

}
